import { defineStore } from "pinia";
import { Item } from "../interface";

export const ordersStore = defineStore("orders", {
  state: () => {
    let orders: Array<Item> = [];
    return {
      //订单
      orders: orders,
    };
  },
  getters: {
    //计算总价
    totalPrice: (state) =>
      state.orders.reduce((p: number, c: any) => {
        return p + c.price;
      }, 0),
  },
});
